<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Groups/classes/PhpFox_ComponentGroupViewForumList.class.php, $Author:  $ */



/** Component for display forum list on the main group pagw
 * @version $Id: PhpFox_ComponentGroupViewForumList.class.php
 * @package module.groups
 */
class PhpFox_Mod_Groups_ComponentGroupViewForumList extends BaseComponent
{
    /** Processing method
     */

    function process()
    {
    	$oReq = &App::getRequest();

    	$oGroupService = &$this->_oModule->getService('Groups');

        //check permissions
        $oSecurityService = App::getModuleService('Account', 'Security');
		/* @var $oSecurityService PhpFox_Mod_Account_ServiceSecurity */
		$oSecurityService->checkPerm('groups', array('read_only', 'full'));

        $oForumService = $this->_oModule->getService('GroupForum');
        /* @var $oForumService PhpFox_Mod_Groups_ServiceGroupForum */

        $iGroupId = $oReq->get('id', 0);

        $aGroupData = $oGroupService->getGroupData($iGroupId);

        if ( $aGroupData['pub_forum'] == 'No' && !( (App::getUser('user') && $oGroupService->isMember($iGroupId, App::getUser('user'))) OR App::isStaff() ) )
        {
        	return '';
        }

        $oTpl = $this->_oModule->getTemplate();

        list($aTopics, $iCnt) = $oForumService->getTopicList(array('group_id'=>'='.$iGroupId), 1, 5);

        $oTpl->assign(array(
            'iGroupId'        => $iGroupId,
            'aTopics'    => $aTopics,
            'iCnt'=> $iCnt,
            'sForumCurrentTime'=>time(),
            'sMonthDateFormat' => App::getParam('format.monthdate%'),
            'sMonthDateFormatDot' => App::getParam('format.monthdatedot'),
            'sImageUrl'     => App::getParam('user.pic.url'),
        ));
        $sHtml = $oTpl->fetch('GroupViewForumList.html');
        return $sHtml;
    }
}
?>